<?php
namespace Store\Controller;
use Think\Controller;
class StoreController extends Controller
{
    function _initialize() {
//        session('user_id',16);
//        session('user_name','liguang');
//        session('store_id',1);
//        session('store_name','李氏农庄欢乐园');
        //判断是否登陆
        if(session('store_id')){
            $this->assign('store_id',session('store_id'));
        }else{
           $url = HOME_URL.'/Login/index';
           $this->redirect($url);
        }
    }
    
    /**
     * 功能：UpYun通过Ajax上传图片
     * @param 
     * @return 返回图片的地址
     */
    public function ueditor() {
        $upyun = new \Libs\UpYun();
        $file = $_FILES['upfile'];
        $url = $upyun->upload($file);
        if($url){
            $result = ['state'=>'SUCCESS','url'=>$url,'title'=>$file['name']];
        }  else {
            $result = ['state'=>'图片上传失败！'];
        }
        //$this->ajaxReturn($arr, 'JSON');
        echo json_encode($result);
    }
    
}
